import { createStore, applyMiddleware } from 'redux'//1.创建仓库,中间件
import reducer from "./reducer"//导入根函数
import logger from "redux-logger"//导入中间件
import { persistStore, persistReducer } from 'redux-persist'//导入持久化处理的方法
import storage from 'redux-persist/lib/storage'//设置是存在localstorage还是sessionstorage
var persistedReducer = persistReducer({ key: 'redux', storage }, reducer);//持久化处理根reducer
let store = createStore(persistedReducer, applyMiddleware(logger));//实例化仓库
// 同时导出持久化后的仓库
export var persistor = persistStore(store)
export default store